<?php

  class Register_controller extends CI_Controller
  {

  	  function __construct()
      {
         parent::__construct();
         $this->load->model('user');
     	}
      
     	public function create_user()
     	{
     		   $this->form_validation->set_rules('fname',     'First Name',       'trim|required');
           $this->form_validation->set_rules('lname',     'Last Name',        'trim|required');
           $this->form_validation->set_rules('username',  'Username',         'trim|required|min_length[4]|is_unique[user.username]');
           $this->form_validation->set_rules('password',  'Password',         'trim|required|min_length[4]|max_length[32]');
           $this->form_validation->set_rules('password1', 'Confirm Password', 'trim|required|matches[password]');
           
           if ($this->form_validation->run())
           {
             $this->user->add_user();         
             $data['prompt'] = 'Successfully Added';
             $data['content'] = 'register'; 
             $this->load->view('include/template' ,$data);  
           }
           else
           {
             $data['content'] = 'register';
             $this->load->view('include/template' ,$data);             
           }
     	}
  }

?>